src: enable X509sToArrayOfStrings to skip errors#61784
Open
StefanStojanovic wants to merge 1 commit intonodejs:mainfrom
Open
src: enable X509sToArrayOfStrings to skip errors#61784StefanStojanovic wants to merge 1 commit intonodejs:mainfrom
StefanStojanovic wants to merge 1 commit intonodejs:mainfrom
Conversation
Collaborator
|
Review requested:
|
4801d72 to
88ad793
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #61784 +/- ##
==========================================
- Coverage 89.73% 89.72% -0.02%
==========================================
Files 675 675
Lines 204674 204700 +26
Branches 39330 39338 +8
==========================================
Hits 183667 183667
- Misses 13283 13307 +24
- Partials 7724 7726 +2
🚀 New features to boost your workflow:
|
addaleax
reviewed
Feb 12, 2026
Comment on lines
+1103
to
+1108
| std::string subject_str = "<unknown>"; | ||
| if (subject_bio) { | ||
| auto subject_size = | ||
| BIO_get_mem_data(subject_bio.get(), &subject_data); | ||
| if (subject_size > 0 && subject_data) { | ||
| subject_str = std::string(subject_data, subject_size); |
Member
There was a problem hiding this comment.
Suggested change
| std::string subject_str = "<unknown>"; | |
| if (subject_bio) { | |
| auto subject_size = | |
| BIO_get_mem_data(subject_bio.get(), &subject_data); | |
| if (subject_size > 0 && subject_data) { | |
| subject_str = std::string(subject_data, subject_size); | |
| std::string_view subject_str = "<unknown>"; | |
| if (subject_bio) { | |
| auto subject_size = | |
| BIO_get_mem_data(subject_bio.get(), &subject_data); | |
| if (subject_size > 0 && subject_data) { | |
| subject_str = std::string_view(subject_data, subject_size); |
No good reason to do an extra heap allocation here
| per_process::Debug(DebugCategory::CRYPTO, | ||
| "Skipping system certificate with subject " | ||
| "'%s' because X509 to PEM conversion failed\n", | ||
| subject_str.c_str()); |
Member
There was a problem hiding this comment.
Suggested change
| subject_str.c_str()); | |
| subject_str); |
joyeecheung
reviewed
Feb 12, 2026
| } | ||
|
|
||
| if (skipped > 0) { | ||
| ProcessEmitWarning( |
Member
There was a problem hiding this comment.
I wonder if we should make this an option to the API instead of unconditionally emitting a warning? So if the user uses tls.getCACertifcate, they can choose warn, ignore, throw (or even get a list of errors on the side) when there's an error in parsing these certificates. For NODE_USE_SYSTEM_CA/--use-system-ca, warn is a sensible behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As suggested in the linked issue, this PR relaxes the X509 to PEM conversion by skipping failures for system certs. If conversion fails, Node.js will try to give info about the failed certs if it can. This new behavior is used only on system certs, since for others, the user has control. AFAIK, there is no way to add a reliable test for this, but if someone has an idea, feel free to share it with me.
Fixes: #61636